<template>
	<view>
		<scroll-view :scroll-y="true" class="scrollContent" :enhanced="true" :bounces="false" :show-scrollbar="false">
			<view class="index_container">
				<view class="top mb15">
					<view class="d-flex a-center">
						<!-- <view class="user_img">
					<u--image src="https://cdn.uviewui.com/uview/album/1.jpg" width="72rpx" height="72rpx"
						shape="circle"></u--image>
				</view> -->
						<view class="user_title ml15">你好，{{userInfo.housekeeperName || praseStrEmpty}}</view>
					</view>
				</view>
				<view class="center p15 mb15">
					<view class="d-flex a-center j-sb">
						<view class="d-flex flex-column a-center">
							<view class="center_title mb10">客户数量</view>
							<view class="center_value">{{userInfo.myCustomerCount || praseStrEmpty}}</view>
						</view>
						<view class="d-flex flex-column a-center">
							<view class="center_title mb10">订单数量</view>
							<view class="center_value">{{userInfo.myOrderCount || praseStrEmpty}}</view>
						</view>
						<view class="d-flex flex-column a-center">
							<view class="center_title mb10">提成总金额</view>
							<view class="center_value">{{userInfo.commissionAllAmount || praseStrEmpty}}</view>
						</view>
					</view>
				</view>
				<view class="bottom">
					<view class="d-flex flex-wrap j-sb">
						<view class="d-flex a-center bottom_item" v-for="(item,index) in menuList" :key="index"
							@click="goToPage(item.menuUrl)">
							<view class="mr10">
								<u-icon size="32" :name="item.menuIcon"></u-icon>
							</view>
							<view class="bottom_item_title">{{item.menuName}}</view>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		queryHomePagePlatformApp
	} from "@/api/index.js"

	export default {
		data() {
			return {
				userInfo: {},
				menuList: [],
				scrollviewHigh: ""
			};
		},
		onLoad() {
			this.userInfo = uni.getStorageSync('housekeeperInfo')
		},
		onShow() {
			uni.hideHomeButton()
			this.queryHomePagePlatformApp()
		},

		mounted() {
			// this.init();
		},
		methods: {
			queryHomePagePlatformApp() {
				uni.showLoading({
					title: '加载中',
					mask: true
				});
				queryHomePagePlatformApp({
					housekeeperCode: this.userInfo.housekeeperCode
				}).then(res => {
					this.menuList = res.object.menuVOList
					this.userInfo.myCustomerCount = res.object.housekeeperInfo.myCustomerCount
					this.userInfo.myOrderCount = res.object.housekeeperInfo.myOrderCount
					this.userInfo.commissionAllAmount = res.object.housekeeperInfo.commissionAllAmount
					uni.hideLoading()
				})
			},

			/*初始化*/
			init() {
				let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
				console.log(menuButtonInfo, '+++++++++++++');
				let _this = this;
				uni.getSystemInfo({
					success(res) {
						console.log(res, '***********');
						_this.phoneHeight = res.windowHeight;
						let view = uni.createSelectorQuery().select('.top_head');
						view.boundingClientRect(data => {
							// console.log(data, '+++++++++++++');
							// let h = _this.phoneHeight - data.height;
							// _this.scrollviewHigh = h;
						}).exec();
					}
				});
			},

			async queryDeviceInfo() {
				await queryDeviceInfo({
					roleCode: this.userInfo.roleCode
				}).then(res => {
					this.deviceInfo = res.object
				})
			},

			goToPage(url) {
				uni.navigateTo({
					url: url
				});
			},
		}
	};
</script>

<style lang="scss" scoped>
	page {
		// background-color: #f5f5f5;
	}

	.scrollContent {
		//可视高度，需要在多大的盒子中进行滑动
		height: 100vh;
		width: 100%;
	}

	.index_container {
		box-sizing: border-box;
		padding: 30rpx 28rpx;
		min-height: 100vh;
		background: linear-gradient(179deg, #46ebb0 0%, #ffffff 80%);
		font-family: Source Han Sans CN, Source Han Sans CN-500;

		.top {

			.user_title {
				font-size: 40rpx;
				font-weight: 600;
				color: #ffffff;
			}
		}

		.center {
			background: #52dc9a;
			border-radius: 8px;
			// box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);

			.center_title {
				font-size: 28rpx;
				color: #fff;
			}

			.center_value {
				font-size: 52rpx;
				color: #fff;
				font-family: Impact, Impact-400;
				font-weight: 600;
			}
		}

		.bottom {
			.bottom_item {
				box-sizing: border-box;
				width: 332rpx;
				padding: 60rpx 40rpx;
				margin-bottom: 30rpx;
				background: #ffffff;
				border-radius: 24rpx;
				box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);

				.bottom_item_title {
					font-size: 32rpx;
					color: #333333;
					font-weight: 600;
				}
			}
		}

	}
</style>